package com.cty.servlet.servlet3;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Auther: cty
 * @Date: 2020/2/20 20:41
 * @Description:
 * @version: 1.0
 */
@WebServlet(name = "LoginServlet")
public class LoginServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String str = (String) req.getAttribute("str");  // 从request作用域获取数据

        resp.getWriter().write("<html>");
        resp.getWriter().write("<head>");
        resp.getWriter().write("<title>login</title>");
        resp.getWriter().write("</head>");
        resp.getWriter().write("<body>");
        resp.getWriter().write("<h1>欢迎登录</h1>");
        resp.getWriter().write("<b>request作用域中的数据为："+str+"</b>");
        resp.getWriter().write("</body>");
        resp.getWriter().write("</html>");
    }
}
